import { Blog } from 'src/blog/blog.entity';
import { Entity, Column, PrimaryGeneratedColumn, CreateDateColumn, UpdateDateColumn, ManyToOne, OneToMany, RelationId } from 'typeorm';

@Entity()
export class Comment {
    @PrimaryGeneratedColumn()
    id: number;

    @Column({
        nullable: false
    })
    nickName: string;

    @Column()
    email: string;

    @Column()
    content: string;

    @Column()
    avatar: string;

    @CreateDateColumn({
        type: "timestamp",
        comment: '创建时间'
    })
    createTime: Date

    @UpdateDateColumn({
        type: "timestamp",
        comment: '更新时间'
    })
    updateTime: Date

    @ManyToOne(type => Blog, blog => blog.comments)
    blog: Blog

    @Column()
    blogId: number

    @OneToMany(type=> Comment, replyComment => replyComment.parentComment)
    replyComments: Comment[]

    @ManyToOne(type => Comment, parentComment => parentComment.replyComments)
    parentComment: Comment

    @Column({
        nullable: true
    })
    parentCommentId: number

    //是否是管理员
    @Column({
        default: false
    })
    adminComment: boolean
}